{php include wl_template('common/header');}
{if $config['base']['meiqia']>0}
<script type='text/javascript'>
    (function(m, ei, q, i, a, j, s) {
        m[a] = m[a] || function() {
            (m[a].a = m[a].a || []).push(arguments)
        };
        j = ei.createElement(q),
            s = ei.getElementsByTagName(q)[0];
        j.async = true;
        j.charset = 'UTF-8';
        j.src = i + '?v=' + new Date().getUTCDate();
        s.parentNode.insertBefore(j, s);
    })(window, document, 'script', '//static.meiqia.com/dist/meiqia.js', '_MEIQIA');
    _MEIQIA('entId', {$config['base']['meiqia']});
	</script>
	{/if}
		<!--<link href="{TG_URL_ARES}css/common.css" rel="stylesheet">
		<link href="{TG_URL_ARES}css/list2.css" rel="stylesheet">
		<link href="{TG_URL_ARES}css/allgoods_common.css" rel="stylesheet">
		<link href="//cdn.bootcss.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet">
		<style>
			.h_fix {
				position: fixed;
				background-color: #fff;
				border-bottom: 1px solid #d5d5d5;
				box-shadow: 0 1px 3px 0px rgba(160, 160, 160, 0.2);
			}
		</style>
		<div class="g-body">
			<div class="m-list">
				<div class="g-wrap g-body-hd m-list-nav" style="">
					<div class="m-list-nav-catlog">
						<a href="javascript:void(0)" class="open"><span id="categoryName">商品分类</span><i class="ico ico-arrow ico-arrow-s-gray ico-arrow-down"></i></a>
					</div>
					<div class="m-list-types">
						<ul class="m-list-types-list">
							<input type="hidden" name="parent" id="parent" value="allgoods" />
							<li onclick="chooseChild('人气',this);">
								<a href="#">人气</a>
							</li>
							<li class="" onclick="chooseChild('最新',this);">
								<a href="#">最新</a>
							</li>
							<li class="" onclick="chooseUpDown(this);">
								<a href="#">销量</a>
							</li>
							<li class="" onclick="chooseAllUpDown(this);">
								<a href="#">好评<i class="ico ico-sort2Arrow"></i></a>
							</li>
						</ul>
					</div>
					<div class="m-list-catlog" style="display: none;">
						<ul class="m-list-catlog-list">
							<li class="selected"><a href="{php echo $this->createMobileUrl('allgoods');}"><i class="ico ico-type ico-type-0"></i>全部商品</a></li>
							{loop $category $item}
							<li onclick="chooseParent('{$item['name']}',this);"><a><i class="{$item['thumb']}" style="font-size: 16px;"></i>&nbsp;{$item['name']}</a></li>
							{/loop}
						</ul>
					</div>
				</div>
			</div>
		</div>-->
<div class="page-group">
	
    <div class="page page-current" id="page-goods-list">
		<div class="content infinite-scroll native-scroll" data-distance="10">
		<div class="topbar"><h3 class="title">拼团</h3><div class="barfn"><i class="refresh"></i><i class="share"></i></div></div>
	    <!--<div class="address">
	        <i class="pos"></i><span class="zone">全国发货</span><span class="zoneTip">（点击这里选择更多地区）</span><i class="arrow"></i>
	    </div>-->
	    {php include wl_template('common/followed');}
	    <div class="banner" id="banner" style="visibility: visible;">
	        <ul class="imgs">
	        	{loop $advs $adv}
	        	<li {if !empty($adv['link'])} onclick="document.location = '{$adv['link']}'"{else}#{/if}>
	        		<img src="{php echo tomedia($adv['thumb'])}">
	        	</li>
	        	{/loop}
	        </ul>
	        <ul class="dotList">
	        	{php $slideNum = 1;} {loop $advs $adv}
					<li{if $slideNum==1 } class="cur" {/if}></li>
				{php $slideNum++;} {/loop}
	        </ul>
	    </div>
	    <script>
		    $(function() {
		        new Swipe($('#banner')[0], {
		            speed:500,
		            auto:3000,
		            callback: function(){
		                var lis = $(".dotList").children();
		                lis.removeClass("cur").eq(this.index).addClass("cur");
		            }
		        });
		    });
		</script>
	    {if $category}
		<div class="j-rmd-types rmd-types">
			{loop $category $itme}
            <a href="{php echo app_url('goods/list/display', array('gid' => $itme['id']));}" class="external">
                <img src="{php echo tomedia($itme['thumb']);}" alt="">
                <span>{$itme['name']}111</span>
            </a>
            {/loop}
    	</div>
    	{/if}
	    <div class="appCode" style="display: none;">
	        <div class="codeBox imgShow">
	            <img src="" alt="">
	        </div>
	        <div class="codeBox codeRight">
	          <p><i></i><span class="des"></span></p>
	          <div class="inputZone">
	                <div style="display: inline-block;float: left;width:70%;">
	                    <input type="text" placeholder="" id="codeInput">  
	                </div>
	                <div style="display: inline-block;width:30%">
	                    <span class="codeBtn">确认</span>
	                </div>
	          </div>
	        </div>
	    </div>
	    <div class="list">
	        <div class="listCon">
	        <ul class="ul_1">
	        </ul>
	        </div>
	        <div class="loading_more" style="padding-top: 15px;display: none;"><span class="loading"><i class="icon_load"></i>加载中......</span></div>
	        <div class="error">加载失败，点击重新加载</div>
	        <div class="noData">全部数据加载完毕</div>
	    </div>
	    <div class="mask"></div>
	    <div class="dialog">
	        <h5>可配送地区</h5>
	        <div class="zone">
	            <i></i>
	            <p>全国发货</p>
	            <div>全国大部分区域</div>
	        </div>
	        <p class="advance" style="display: block;">华东区，华南区，华中区，<br>西北区，西南区，东北区，<br>更多地区玩命开通中</p>
	    </div>
		<div class="bg_layer" style="height: 6672px; opacity: 0; display: none;"></div>
		<div class="dialog_box" style="top: 308px; opacity: 0; display: none;">
			<div class="zoneList"><h4>选择地区</h4><div class="zoneOuter">
				<ul>
					<li class="noBorder " data-actid="3"><div><h5>华北地区</h5><p>北京 天津 河北 山东 山西</p></div></li>
					<li class="noBorder selected" data-actid="15"><div><h5>全国发货</h5><p>全国大部分区域</p></div></li>
				</ul>
			</div></div>
		</div>
		</div>
		
		{php include wl_template('common/footerbar');}
	</div>
</div>

<script type="text/html" id="goodslist">
{{# for(var i = 0, len = d.list.length; i < len; i++){ }}
<li class="gli">
	<a href="{{ d.list[i].a }}" class="external">
		<div class="img"><img src="{{ d.list[i].gimg }}" alt="" style="opacity: 1;"><div class="icon_position"><div class="discount"><span>{{ Math.round((d.list[i].gprice/d.list[i].mprice)*10) }}折<br>{{ d.list[i].groupnum }}人团</span></div>
		{{# if(d.list[i].goodstab != null && typeof(d.list[i].goodstab.length) != "undefined" && d.list[i].goodstab){ }}
		<div class="pricedown">{{ d.list[i].goodstab }}</div>
		{{# } }}
		</div>
		{{# var lenn = d.list[i].params.length; if(lenn >= 3){ }}
		<ul class="desPos">
			<li class="firstLine " expos="0">{{ d.list[i].params[0].value }}</li>
			<li class="" expos="0">{{ d.list[i].params[1].value }}</li>
			<li class="lastLine" expos="0">{{ d.list[i].params[2].value }}</li>
		</ul>
		{{# } }}
		</div>
		<div class="txt"><h5>{{ d.list[i].gname }}</h5><p>{{ d.list[i].goodsdesc }}</p></div><div class="fnWrap"><div class="fnZone"><i></i><span><b class="price">￥{{ d.list[i].gprice }}/{{ d.list[i].unit }}</b><b class="people">{{ d.list[i].groupnum }}人团</b></span><span class="btn">去开团 &gt;</span></div>
		</div>
	</a>
</li>
{{# } }}
</script>
<script>
	$(function() {
		'use strict';
		//商品列表页
		$(document).on("pageInit", "#page-goods-list", function(e, id, page) {
			var loading = false;
			var thispagesize = 4;
			var thispagesizemax = 100;
			var thispage = 1;

			function addItems(thispage, thispagesize) {
				var ajaxurl = "{php echo app_url('goods/list/ajax',array('cid' => $cid))}" + "&page=" + thispage + "&pagesize=" + thispagesize;
				$.ajax({
					type: "POST",
					url: ajaxurl,
					dataType: 'json',
					beforeSend: function(XMLHttpRequest) {},
					success: function(data) {
						thispagesizemax = data.total;
						if (data.list.length > 0) {
							var gettpl = document.getElementById('goodslist').innerHTML;
							laytpl(gettpl).render(data, function(html){
							    $(".ul_1").append(html);
							});
						} else {
							$(".loading_more").remove();
							$('.noData').show();
						}
					},
					error: function() {
						$('.error').show();
					}
				});
			}
			addItems(thispage, thispagesize);
			$(page).on('infinite', function() {
				if (loading) return;
				loading = true;
				$(".loading_more").show();
				setTimeout(function() {
					loading = false;
					thispage++;
					addItems(thispage, thispagesize);
					$(".loading_more").hide();
					$.refreshScroller();
				}, 1000);
			});
		});
		$.init();
	});
</script>

{php include wl_template('common/footer');}
	